package com.he.DesignPatterns.strategy.flyweight;

/**
 * @description: 享元测试类
 * @Author: HCL
 * @Date: 2024/9/3 16:05
 */
public class Client {

    public static void main(String[] args) {
        Flyweight flyweight1 = FlyweightFactory.getFlyweight("key1");
        flyweight1.show("200");
        System.out.println("========================");

        Flyweight flyweight2 = FlyweightFactory.getFlyweight("key2");
        flyweight2.show("200");
        System.out.println("========================");

        Flyweight flyweight3 = FlyweightFactory.getFlyweight("key1"); //对象之前创建过，还是使用的之前的对象
        flyweight3.show("200");
        System.out.println(flyweight1 == flyweight3);
    }
}
